import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { GraveVO, GraveForm, GraveQuery,ParkVO, ParkQuery, ParkForm } from '@/api/cemetery/grave/types';

/**
 * 查询墓穴列表
 * @param query
 * @returns {*}
 */

export const listGrave = (query?: GraveQuery): AxiosPromise<GraveVO[]> => {
  return request({
    url: '/cemetery/grave/list',
    method: 'get',
    params: query
  });
};

export const graveRecord = (query?: GraveQuery): AxiosPromise<GraveVO[]> => {
  return request({
    url: '/cemetery/graveRecord/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询墓穴详细
 * @param id
 */
export const getGrave = (id: string | number): AxiosPromise<GraveVO> => {
  return request({
    url: '/cemetery/grave/' + id,
    method: 'get'
  });
};


/**
 * 新增墓穴
 * @param data
 */
export const addGrave = (data: GraveForm) => {
  return request({
    url: '/cemetery/grave',
    method: 'post',
    data: data
  });
};

/**
 * 修改墓穴
 * @param data
 */
export const updateGrave = (data: GraveForm) => {
  return request({
    url: '/cemetery/grave',
    method: 'put',
    data: data
  });
};
/**
 * 业务办理，预留修改
 * @param data
 */
export const businessGrave = (data: GraveForm) => {
  return request({
    url: '/cemetery/grave/business',
    method: 'put',
    data: data
  });
};

/**
 * 删除墓穴
 * @param id
 */
export const delGrave = (id: string | number | Array<string | number>) => {
  return request({
    url: '/cemetery/grave/' + id,
    method: 'delete'
  });
};


/**
 * 查询墓穴园区树
 * @param query
 * @returns {*}
 */

export const listParkTreeList = (query) => {
  return request({
    url: '/cemetery/park/treeList',
    method: 'get',
    params: query
  });
};



/**
 * 新增墓穴园区
 * @param data
 */
export const addPark = (data: ParkForm) => {
  return request({
    url: '/cemetery/park',
    method: 'post',
    data: data
  });
};
/**
 * 新增墓穴园区批量
 * @param data
 */
export const addBatchPark = (data: ParkForm) => {
  return request({
    url: '/cemetery/park/batchAdd',
    method: 'post',
    data: data
  });
};
/**
 * 删除墓穴园区
 * @param id
 */
export const delPark = (id: string | number | Array<string | number>) => {
  return request({
    url: '/cemetery/park/' + id,
    method: 'delete'
  });
};
/**
 * 查询墓穴详细
 * @param id
 */
export const getPark = (id: string | number): AxiosPromise<ParkVO> => {
  return request({
    url: '/cemetery/park/' + id,
    method: 'get'
  });
};
